define("@wsb/guac-widget-shared/lib/components/DynamicFontScaler-d6821741.js",["exports","~/c/_rollupPluginBabelHelpers","~/c/dynamicFontScaler"],function(t,e,n){"use strict";function o({containerId:t,targetId:e,fontSizes:n,maxLines:o,prioritizeDefault:r}){if("undefined"==typeof document)return;let i;const s=document.getElementById(t),a=document.getElementById(e);function c(t){return function(t){const e=parseInt(g(t,"padding-left")||0,10),n=parseInt(g(t,"padding-right")||0,10);return t.scrollWidth+e+n}(t)<=s.clientWidth&&function(t){const e=t.offsetHeight,n=parseInt(g(t,"line-height"),10)||1;return Math.floor(e/n)}(t)<=o}function l(t){return parseInt(g(t,"font-size")||0,10)}function p(t){if(1===t.length)return t[0];const e=t.filter(c);if(1===e.length)return e[0];if(!e.length)return function(t){return t.sort((t,e)=>l(t)-l(e))[0]}(t);return e.sort((t,e)=>l(e)-l(t))[0]}function d(){if(!s||!a||i===window.innerWidth)return;if(a.hasAttribute("data-font-scaled"))return void u();i=window.innerWidth;const o=Array.prototype.slice.call(s.querySelectorAll(`[data-scaler-id="scaler-${t}"]`)).sort((t,e)=>n.indexOf(t.getAttribute("data-size"))-n.indexOf(e.getAttribute("data-size")));if(s.clientWidth&&o.length){const t=s.style.width||"";s.style.width="100%",o.forEach(t=>{t.style.display="inline-block",t.style.maxWidth=`${s.clientWidth}px`});const n=p(o);!function(t){t.forEach(t=>{t.style.display="none",t.style.maxWidth=""})}(o),s.style.width=t;const i=g(n,"font-size"),c=a.getAttribute("data-last-size");if(i&&i!==c){if(r){const t=g(a,"font-size");if(parseInt(i,10)>=parseInt(t,10))return}a.setAttribute("data-last-size",i);let t=document.querySelector(`#${e}-style`);t||(t=document.createElement("style"),t.id=`${e}-style`,document.head.appendChild(t)),t.textContent=`#${a.id} { font-size: ${i} !important; }`}}}function u(){a&&a.removeAttribute("data-last-size");const t=document.querySelector(`#${e}-style`);t&&t.parentNode.removeChild(t)}function g(t,e){return document.defaultView.getComputedStyle(t).getPropertyValue(e)}return d(),window.addEventListener("resize",d),()=>{u(),window.removeEventListener("resize",d)}}const{Bootstrap:r}=(global.Core||guac["@wsb/guac-widget-core"]).components,{XXLARGE:i,XLARGE:s,LARGE:a}=(global.Core||guac["@wsb/guac-widget-core"]).constants.fontSizes,{PUBLISH:c}=(global.Core||guac["@wsb/guac-widget-core"]).constants.renderModes;class l extends(global.React||guac.react).Component{getDynamicFontScaler(){return n.d({...this.props})}componentDidUpdate(){this.invokeScript()}componentDidMount(){this.invokeScript()}invokeScript(){const{scriptOnly:t,renderMode:e}=this.props;t&&e===c||(this.detachScript(),this._detachScript=o(this.getDynamicFontScaler().scriptProps))}detachScript(){this._detachScript&&this._detachScript()}componentWillUnmount(){this.detachScript()}render(){const{renderMode:t,scriptOnly:e}=this.props;if(e)return t===c?(global.React||guac.react).createElement(r.JS,{id:"DynamicFontScaler",script:o.toString(),scriptOnly:!0}):(window.wsb=window.wsb||{},window.wsb.DynamicFontScaler=window.wsb.DynamicFontScaler||o,null);const{element:n,scriptProps:i}=this.getDynamicFontScaler();return t===c?(global.React||guac.react).createElement((global.React||guac.react).Fragment,null,n,(global.React||guac.react).createElement(r.JS,{id:"DynamicFontScaler",script:o.toString(),props:i})):n}}e.a(l,"propTypes",{typography:(global.PropTypes||guac["prop-types"]).string,text:(global.PropTypes||guac["prop-types"]).string.isRequired,containerId:(global.PropTypes||guac["prop-types"]).string.isRequired,font:(global.PropTypes||guac["prop-types"]).string,renderMode:(global.PropTypes||guac["prop-types"]).oneOf(Object.values((global.Core||guac["@wsb/guac-widget-core"]).constants.renderModes)),targetId:(global.PropTypes||guac["prop-types"]).string.isRequired,fontSizes:(global.PropTypes||guac["prop-types"]).arrayOf((global.PropTypes||guac["prop-types"]).oneOf(Object.values((global.Core||guac["@wsb/guac-widget-core"]).constants.fontSizes))),style:(global.PropTypes||guac["prop-types"]).object,maxLines:(global.PropTypes||guac["prop-types"]).number,Tag:(global.PropTypes||guac["prop-types"]).node,prioritizeDefault:(global.PropTypes||guac["prop-types"]).bool,scriptOnly:(global.PropTypes||guac["prop-types"]).bool}),e.a(l,"defaultProps",{fontSizes:[i,s,a],scriptOnly:!1}),t.default=l,Object.defineProperty(t,"__esModule",{value:!0})}),"undefined"!=typeof window&&(window.global=window); //# sourceMappingURL=DynamicFontScaler-d6821741.js.map